<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <title>登录</title>
    <%include("../inc/lib.html"){}%>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-4 col-md-offset-4">
            <div class="login-panel panel panel-default" style="margin-top:20%;">
                <div class="panel-heading">
                    <h3 class="panel-title">Please Sign In</h3>
                </div>
                <div class="panel-body">
                    <form role="form">
                        <fieldset>
                            <div class="form-group">
                                <input class="form-control" placeholder="E-mail" autocomplete="off" name="email"
                                       id="email" type="email" autofocus>
                            </div>
                            <div class="form-group">
                                <input class="form-control" placeholder="Password" autocomplete="off" id="password"
                                       name="password" type="password" value="">
                            </div>
                            <a href="javascript:void(0);" class="btn btn-lg btn-success btn-block"
                               id="loginBtn">Login</a>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $('#loginBtn').click(function(){
            var $loginBtn = $(this);
            if(!$loginBtn.attr('disabled')){
                $loginBtn.attr('disabled',true);
                $.post('${ctxPath}/user/loginValidate',{'name':$('#email').val()},function(data){
                    try{
                        data = eval("("+data+")")
                    }catch(e){
                        console.log(e)
                    }
                    if(data['name']=='admin'){
                        window.location = '${ctxPath}/user/toAzyIndexView';
                    } else {
                        $loginBtn.attr('disabled',false);
                    }
                });
            }
        });
    });

</script>
</body>
</html>
